function getImages()	{
	chrome.tabs.getSelected(null, function(tab) {
	  chrome.tabs.sendRequest(tab.id, {greeting: "hello"}, function(response) {
		var biggest = response.myBiggest;
		var allImages = response.allImages;
		
		var slideshow = document.getElementById("slideshow");
		slideshow.innerHTML="";
		
		var bigImg = document.createElement("image");
		bigImg.src = biggest;
		bigImg.id = "biggest";
		bigImg.setAttribute("onclick", "showImage("+tab.id+")");
		bigImg.setAttribute("style", "max-width:300px;min-width:100px;cursor:pointer;");
		slideshow.appendChild(bigImg);
		
		var br = document.createElement("br");
		slideshow.appendChild(br);

		var hr = document.createElement("hr");
		slideshow.appendChild(hr);

		for(var image in allImages)	{
			var img = document.createElement("image");
			img.src = allImages[image];
			img.width = "50";
			img.setAttribute("onclick", "changeImage('"+allImages[image]+"')");
			img.setAttribute("style", "cursor:pointer;");
			slideshow.appendChild(img);
		}
	  });
	});
}

function changeImage(imgsrc)	{
	var biggest = document.getElementById("biggest");
	biggest.src = imgsrc;
	if(bigImg.width>300)	{
		bigImg.width = "300";
	}
}

function showImage(tabId)	{
	var biggest = document.getElementById("biggest");
	var imgsrc = biggest.src;
	//chrome.tabs.create({url:imgsrc,selected:false});
	chrome.tabs.update(tabId,{url:imgsrc});
	//getImages();
}

getImages();